package work.shuangzhizhen;

import java.util.Map;

public class Problem11 {
    public int maxArea(int[] height) {

        int head = 0, tail = height.length - 1;
        int max = 0;
        while (head != tail) {
            boolean b = height[head] > height[tail];
            if (b) {
                int result = height[tail] * (tail - head);
                max = Math.max(result, max);
                tail--;
            } else {

                int result = height[head] * (tail - head);
                max = Math.max(result, max);
                head++;
            }
        }
        return max;
    }


    public int maxArea1(int[] height) {
        int first = 0, tail = height.length - 1, volumeMax = 0;
        while (first <= tail) {
            if (height[first] > height[tail]) {
                int volume = height[tail] * (tail - first);
                volumeMax = Math.max(volume, volumeMax);
                tail--;
            } else {
                int volume = height[first] * (tail - first);
                volumeMax = Math.max(volume, volumeMax);
                first++;
            }
        }
        return volumeMax;
    }




}
